package org.answer.controller;

import org.answer.constant.MessageConstant;
import org.answer.entity.PageResult;
import org.answer.entity.QueryPageBean;
import org.answer.entity.Result;
import org.answer.service.BehaviorLogService;
import org.apache.dubbo.config.annotation.Reference;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/behaviorlog")
public class BehaviorLogController {

    @Reference
    private BehaviorLogService behaviorLogService;

    @RequestMapping("/findPage")
    public PageResult findPage(@RequestBody QueryPageBean queryPageBean){
        return behaviorLogService.pageQuery(queryPageBean);
    }

    @RequestMapping("/delete")
    public Result delete(Integer id){
        try {
            behaviorLogService.delete(id);
            return new Result(true, MessageConstant.DELETE_BEHAVIORLOG_SUCCESS);
        }catch (Exception e){
            e.printStackTrace();
            return new Result(false,MessageConstant.DELETE_BEHAVIORLOG_FALL);
        }
    }

}
